Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: vm rpc encoding #8288

Merged
merged 6 commits into from
Jun 28, 2024
Merged

Conversation

mattsse
Copy link
Member

@mattsse mattsse commented Jun 28, 2024

closes #8287

@DaniPopes @klkvr I'm not sure what the appropriate behaviour here would be, but I think ensuring the cheatcode returns the abiencoded rpc response as abi bytes makes sense, but maybe we don't double encode if the DynSolValue is already Bytes?

I guess this breaks existing tests, maybe this should really just convert dynsolvariants that don't encode to bytes?

@klkvr
Copy link
Member

klkvr commented Jun 28, 2024

yeah, I think people might already rely on string and bytes being encoded that way, and I believe for objects this is always reverting, so it wouldn't be a breaking change if we enable this kind of encoding for them

@mattsse
Copy link
Member Author

mattsse commented Jun 28, 2024

right, the issue in #8287 is for fixed bytes (eth_getStorageAt),

I changed the fix and mapped those to Bytes instead

{
DynSolValue::FixedBytes(bytes, _) => {
// converted fixed bytes to bytes to prevent evm encoding issues: <https://github.com/foundry-rs/foundry/issues/8287>
DynSolValue::Bytes(bytes.to_vec())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be vec![_; 32] for bytes31, bytes30 ... is this right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bytes.as_slice()[..size].to_vec()?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah

@DaniPopes
Copy link
Member

Does the same apply to Address?

@mattsse
Copy link
Member Author

mattsse commented Jun 28, 2024

maybe, but I'm not aware of any rpc call that returns an address, but I've added it

@mattsse mattsse requested a review from DaniPopes June 28, 2024 15:17
@DaniPopes DaniPopes merged commit b3c872b into foundry-rs:master Jun 28, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

calling vm.rpc reverts for no reason
3 participants